<section>
    <section class="vbox">
        <section class="scrollable padder">
            <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
                <li><a href="{:url('Home/index')}"><i class="fa fa-home"></i> 首页</a></li>
                <li class="active">用户操作</li>
            </ul>
            <div class="m-b-md">
                <h3 class="m-b-none">用户操作
                    <a href="{:url('User/index',array('page'=>$page,'search'=>$search))}"
                        class="btn btn-s-md btn-default">返&nbsp;&nbsp;回</a>
                </h3>
            </div>
            <section class="panel panel-default">
                <div class="row m-l-none m-r-none bg-light lter">
                    <form method="post" action="{:url('User/edit',array('page'=>$page,'search'=>$search))}"
                        enctype="multipart/form-data">
                        <input type="text" class="form-control" id="id" name="id" value="{$res.id?$res.id:''}"
                            style="width:300px;display: none">
                        <div class="table-responsive">
                            <table class="table table-striped b-t b-light">
                                <tbody>
                                    <tr>
                                        <th style="vertical-align: middle;">头像（最大4M）：</th>
                                        <td>
                                            <div style="width: fit-content;text-align: center;">
                                                <div id="upload-img">
                                                    <img src="{$res.avatar_img?$res.avatar_img:'__PIC__'}"
                                                        id="update_img" style="width: 20rem;">
                                                </div>
                                                <input type="file" id="img" name="img">
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th style="vertical-align: middle;width:15%">昵称：</th>
                                        <td>
                                            <input type="text" class="form-control" id="nick_name" name="nick_name"
                                                value="{$res.nick_name?$res.nick_name:''}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th style="vertical-align: middle;width:15%">手机：</th>
                                        <td>
                                            <input type="text" class="form-control" id="phone" name="phone"
                                                value="{$res.phone?$res.phone:''}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th style="vertical-align: middle;width:15%">真实姓名：</th>
                                        <td>
                                            <input type="text" class="form-control" id="true_name" name="true_name"
                                                value="{$res.true_name?$res.true_name:''}">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th style="vertical-align: middle;width:15%">生日：</th>
                                        <td>
                                            <input type="text" class="combodate form-control" data-format="YYYY-MM-DD"
                                                data-template="YYYY-MM-DD" name="birthday" id="birthday"
                                                value="{$res.birthday?$res.birthday:$res.birthday}" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <th style="vertical-align: middle;width:15%">职业：</th>
                                        <td>
                                            <input type="text" class="form-control" id="job" name="job"
                                                value="{$res.job?$res.job:''}">
                                        </td>
                                    </tr>
                                    <!-- <tr>
                                        <th style="vertical-align: middle;">状态：</th>
                                        <td>
                                            <select name="status"
                                                style="width:210px;padding: 5px 10px;border: 1px solid #d9d9d9;border-radius: 3px;">
                                                <option value="0" selected>隐藏</option>
                                                <option value="1" {$res.status?($res.status==1?'selected':''):''}>
                                                    正常（取得id）</option>
                                                <option value="2" {$res.status?($res.status==2?'selected':''):''}>
                                                    正常（取得昵称头像）</option>
                                            </select>
                                        </td>
                                    </tr> -->
                                    <tr>
                                        <th></th>
                                        <td>
                                            <input type="submit" value="保存" class="btn btn-s-md btn-success">
                                            <a href="{:url('User/add',array('id'=>empty($res)?'':$res.id,'page'=>$page))}"
                                                class="btn btn-s-md btn-default">取消</a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </form>
                </div>
            </section>
        </section>
    </section>
</section>

<script src="__SITEURL__/kindeditor/kindeditor.js" type="text/javascript"></script>
<script src="__SITEURL__/kindeditor/lang/zh_CN.js" type="text/javascript"></script>
<script src="__SITEURL__/kindeditor/plugins/code/prettify.js" type="text/javascript"></script>
<script>
    $('#img').uploadifive({
        'auto': true,
        'fileType': 'image/*',
        'multi': true,
        'buttonClass': 'uploadifive-button',
        'buttonText': '选择图片(4M以内)',
        'fileSizeLimit': '4MB',
        'uploadScript': "{:url('home/Upload/upload')}",
        'onUploadComplete': function (file, response) {
            var data = JSON.parse(response);
            if (data.response_code == 0) {
                $('#upload-img').append('<div style="display: block;">' +
                    '<input type="hidden" name="avatar_img" value="' + data.data.url + '"></div>');
                document.getElementById('update_img').src = data.data.url;
                //document.getElementById('update_img').style.width = '100%';
            } else {
                alert(data.msg);
            }
        }
    });
</script>